package com.ruoyi.web.controller.gxs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gxs.domain.GxsParenttype;
import com.ruoyi.gxs.service.IGxsParenttypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 扣分父类型Controller
 * 
 * @author 高晓松
 * @date 2023-12-27
 */
@RestController
@RequestMapping("/gxs/parenttype")
public class GxsParenttypeController extends BaseController
{
    @Autowired
    private IGxsParenttypeService gxsParenttypeService;

    /**
     * 查询扣分父类型列表
     */
//    @PreAuthorize("@ss.hasPermi('gxs:parenttype:list')")
    @GetMapping("/list")
    public TableDataInfo list(GxsParenttype gxsParenttype)
    {
        startPage();
        List<GxsParenttype> list = gxsParenttypeService.selectGxsParenttypeList(gxsParenttype);
        return getDataTable(list);
    }

    /**
     * 导出扣分父类型列表
     */
//    @PreAuthorize("@ss.hasPermi('gxs:parenttype:export')")
    @Log(title = "扣分父类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GxsParenttype gxsParenttype)
    {
        List<GxsParenttype> list = gxsParenttypeService.selectGxsParenttypeList(gxsParenttype);
        ExcelUtil<GxsParenttype> util = new ExcelUtil<GxsParenttype>(GxsParenttype.class);
        util.exportExcel(response, list, "扣分父类型数据");
    }

    /**
     * 获取扣分父类型详细信息
     */
//    @PreAuthorize("@ss.hasPermi('gxs:parenttype:query')")
    @GetMapping(value = "/{gxsParenttypeId}")
    public AjaxResult getInfo(@PathVariable("gxsParenttypeId") Long gxsParenttypeId)
    {
        return success(gxsParenttypeService.selectGxsParenttypeByGxsParenttypeId(gxsParenttypeId));
    }

    /**
     * 新增扣分父类型
     */
//    @PreAuthorize("@ss.hasPermi('gxs:parenttype:add')")
    @Log(title = "扣分父类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GxsParenttype gxsParenttype)
    {
        return toAjax(gxsParenttypeService.insertGxsParenttype(gxsParenttype));
    }

    /**
     * 修改扣分父类型
     */
//    @PreAuthorize("@ss.hasPermi('gxs:parenttype:edit')")
    @Log(title = "扣分父类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GxsParenttype gxsParenttype)
    {
        return toAjax(gxsParenttypeService.updateGxsParenttype(gxsParenttype));
    }

    /**
     * 删除扣分父类型
     */
//    @PreAuthorize("@ss.hasPermi('gxs:parenttype:remove')")
    @Log(title = "扣分父类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gxsParenttypeIds}")
    public AjaxResult remove(@PathVariable Long[] gxsParenttypeIds)
    {
        return toAjax(gxsParenttypeService.deleteGxsParenttypeByGxsParenttypeIds(gxsParenttypeIds));
    }
}
